package com.spring.dive.a02interface;

public class GenericTest {

    public static void main(String[] args) {
        // 1.如果已经明确了泛型，创建的时候就不用添加泛型了，类似普通类
        GenericImpl generic = new GenericImpl();
        String key = generic.getKey();
        generic.print("----->只能是"+key+"类型");

        // 2.没有明确泛型，根据实现的类型进行参数接收，默认Object
        GenericImpl2<String> generic2 = new GenericImpl2();
        String key2 = generic2.getKey();
        generic2.print(key2);

        GenericImpl2 generic3 = new GenericImpl2();
        Object key3 = generic3.getKey();
        generic3.print(key3);

        // 3.扩充了泛型,根据实现的类型进行参数接收
        GenericImpl3<String,Integer> genericImpl3 = new GenericImpl3("xiaoming",2000);
        String key1 = genericImpl3.getKey();
        Integer value = genericImpl3.getValue();
        System.out.println("------>key："+key1+"  value："+value);


    }
}
